package com.gjt.thread.Thread;

import java.util.concurrent.Callable;

/**
 * Created with Intel IDEA.
 * 使用Callable 实现线程 并使用简单排序
 *
 * @Auther: gjt
 * @Date: 2024/3/20 20:59
 */
public class SortedCallable implements Callable<int []> {
    // 等待排序的数据
    private int[] data;

    public SortedCallable(int[] data) {
        this.data = data;
    }

    @Override
    public int[] call() throws Exception {
        for(int i = 0; i < data.length; i++){
            for(int j = i+1; j < data.length; j++){
                if(data[i] > data[j]){
                    int temp = data[i];
                    data[i] = data[j];
                    data[j] = temp;
                }
            }
        }
        return data;
    }
}
